<?php if (!isset($page)) $page = 1; ?>
<?php if (!isset($page_size)) $page_size = 10; ?>
<?php if (!isset($total_count)) $total_count = 0; ?>
<?php $delta = 5; ?>
<?php $total_pages_count = ceil($total_count / $page_size); ?>
<?php if ($total_pages_count == 0) $total_pages_count = 1; ?>
<?php $prev_page = $page - 1; ?>
<?php $next_page = $page + 1; ?>
<div class="pagination pagination-right">
<?php if ($total_pages_count > 1): ?>
	<ul>
		<?php if ($page == 1): ?>
		<li class="disabled"><span>&lt;&lt;</span></li>
		<?php else: ?>
		<li><a href="<?=preg_replace("/\[PAGE_NO\]/", 1, $page_url_pattern)?>">&lt;&lt;</a></li>
		<?php endif; ?>
		<?php if ($prev_page < 1): ?>
		<li class="disabled"><span>&lt;</span></li>
		<?php else: ?>
		<li><a href="<?=preg_replace("/\[PAGE_NO\]/", $prev_page, $page_url_pattern)?>">&lt;</a></li>
		<?php endif; ?>
		<?php if ($page > $delta): ?>
		<li class="disabled"><span>...</span></li>
		<?php endif; ?>
		<?php for($i = ($page - 1 > $delta ? $page - $delta : 1); $i <= ($total_pages_count - $page > $delta ? $page + $delta : $total_pages_count); $i++): ?>
			<?php if ($i == $page): ?>
			<li class="disabled"><span><?=$i?></span></li>
			<?php else: ?>
			<li><a href="<?=preg_replace('/\[PAGE_NO\]/', $i, $page_url_pattern)?>"><?=$i?></a></li>
			<?php endif; ?>
		<?php endfor; ?>
		<?php if ($page < $total_pages_count - $delta): ?>
		<li class="disabled"><span>...</span></li>
		<?php endif; ?>
		<?php if ($next_page > $total_pages_count): ?>
		<li class="disabled"><span>&gt;</span></li>
		<?php else: ?>
		<li><a href="<?=preg_replace("/\[PAGE_NO\]/", $next_page, $page_url_pattern)?>">&gt;</a></li>
		<?php endif; ?>
		<?php if ($page >= $total_pages_count): ?>
		<li class="disabled"><span>&gt;&gt;</span></li>
		<?php else: ?>
		<li><a href="<?=preg_replace("/\[PAGE_NO\]/", $total_pages_count, $page_url_pattern)?>">&gt;&gt;</a></li>
		<?php endif; ?>
	</ul>
<?php endif; ?>
</div>